import Combine
import SwiftUI

@MainActor
struct AnimesNavigationView: View {
    @Bindable
    private var coordinator: AnimesCoordinator
    
    private let viewModel: AnimesViewModel

    
    init(coordinator: AnimesCoordinator, viewModel: AnimesViewModel) {
        self.coordinator = coordinator
        self.viewModel = viewModel
    }
    
    var body: some View {
        NavigationStack(path: $coordinator.routes) {
            AnimesListView(viewModel: viewModel)
                .navigationTitle("Animes")
                .navigationDestination(for: AnimesCoordinator.Route.self) { route in
                    switch route {
                    case .animeDetail(let route):
                        AnimeDetailView(viewModel: route.value)
                    }
                }
        }
    }
}

